<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('合同变更登记')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()">
                    <i class="fa fa-plus"></i> 添加员工
                </a>
                <a class="btn btn-primary single" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                &nbsp;&nbsp;&nbsp;
                <a class="btn btn-primary" onclick="threeProcedure('eSP_ContractCheck')">
                    <i class="fa fa-edit"></i> 确认检查
                </a>
                <a class="btn btn-danger" onclick="threeProcedure('eSP_ContractCancel')">
                    <i class="fa fa-remove"></i> 取消确认
                </a>
                <a class="btn btn-primary" onclick="threeProcedure('eSP_ContractStart')">
                    执行处理
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>

<script th:inline="javascript">
    var prefix = ctx + "contractManage/changeContract";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryData();
    });

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var badge = {field: 'badge', title: '工号'};
        var name = {field: 'name', title: '姓名'};
        var compName = {field: 'compName', title: '公司名称'};
        var depName = {field: 'depName', title: '部门名称'};
        var jobName = {field: 'jobName', title: '工作岗位'};
        var ConCount = {field: 'ConCount', title: '合同次数'};
        var ContractTitle = {field: 'ContractTitle', title: '合同签约单位'};
        var ConTypeTitle = {field: 'ConTypeTitle', title: '合同类型'};
        var ConPropertyTitle = {field: 'ConPropertyTitle', title: '合同属性'};
        var ConBeginDate = {field: 'ConBeginDate', title: '合同开始日期'};
        var ConTerm = {field: 'ConTerm', title: '合同(年)'};
        var ConEndDate = {field: 'ConEndDate', title: '合同结束日期'};
        var NewConCount = {field: 'NewConCount', title: '新合同次数'};
        var NewContractTitle = {field: 'NewContractTitle', title: '新合同签约单位'};
        var NewContypeTitle = {field: 'NewContypeTitle', title: '新合同类型'};
        var NewConPropertyTitle = {field: 'NewConPropertyTitle', title: '新合同属性'};
        var NewConBeginDate = {field: 'NewConBeginDate', title: '新合同开始日期'};
        var NewConTerm = {field: 'NewConTerm', title: '新合同期(年)'};
        var NewConEndDate = {field: 'NewConEndDate', title: '新合同结束日期'};
        var EffectDate = {field: 'EffectDate', title: '生效日期'};
        var remark = {field: 'remark', title: '备注'};
        var RegByName = {field: 'RegByName', title: '登记人'};
        var RegDate = {field: 'RegDate', title: '登记时间'};
        var Initialized = {field: 'Initialized', title: '?确认'};
        var InitializedByName = {field: 'InitializedByName', title: '确认人'};
        var InitializedTime = {field: 'InitializedTime', title: '确认时间'};

        columns.push(checkbox,id,badge,name,compName,depName,jobName,ConCount,ContractTitle,ConTypeTitle);
        columns.push(ConPropertyTitle,ConBeginDate,ConTerm,ConEndDate,NewConCount,NewContractTitle,NewContypeTitle);
        columns.push(NewConPropertyTitle,NewConBeginDate,NewConTerm,NewConEndDate,EffectDate,remark,RegByName);
        columns.push(RegDate,Initialized,InitializedByName,InitializedTime);

        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/findDataList",
            createUrl: prefix + "/addEmp",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            detailUrl: prefix + "/detail/{id}",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "合同变更登记",
            columns: columns
        };
        $.table.init(options);
    }

    function threeProcedure(procedure) {
        var allId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        $.ajax({
            url: ctx + "contractManage/threeProcedure",
            data: {"allId": allId, "procedure": procedure},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.data == null) {
                    $.modal.alertWarning(data.message);
                } else {
                    $.modal.alertSuccess(data.data);
                }

                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }


</script>
</body>
</html>